<template>
	<view>
		<view class="form">
			<view class="item">
				<view class="lable">原密码</view>
				<view class="text">
					<input type="safe-password" password="false" v-model="userInfo.oldPassword" placeholder="请输入原密码" />
				</view>
			</view>
			<view class="item">
				<view class="lable">新密码</view>
				<view class="text">
					<input type="safe-password" password="false" v-model="userInfo.newPassword" placeholder="请输入新密码" />
				</view>
			</view>
			<view class="item">
				<view class="lable">确认密码</view>
				<view class="text">
					<input type="safe-password" password="false" v-model="userInfo.confirmPassword"
						placeholder="请再次输入新密码" />
				</view>
			</view>
		</view>
		<view class="updata">
			<button type="primary" @click="updata">确认修改</button>
			<button @click="goBack()">返回</button>
		</view>
	</view>
</template>

<script>
	import {
		updataUserPwd
	} from '@/api/system/user'

	export default {
		components: {},
		data() {
			return {
				userInfo: {
					oldPassword: '',
					newPassword: '',
					confirmPassword: ''
				}
			}
		},
		methods: {
			updata() {
				const app = this
				updataUserPwd(app.userInfo.oldPassword, app.userInfo.newPassword).then(result => {
					if (result.data.code == 200) {
						this.$showToast('修改成功', 'success', 2000);
					} else {
						this.$showToast(result.data.msg, 'error', 2000);
					}
				})
			},
			goBack() {
				uni.navigateBack({
					delta: 1
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import '../profile.scss';
</style>